package com.wdm.diffutils.user;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.Collections;
import java.util.List;

/**
 * @author: wudaiming
 * @date: 2023/10/26
 * @version: 1.0
 * @description:
 */
@Data
@AllArgsConstructor
public class User implements Comparable<User> {
    private Integer id;
    private String userName;
    private String address;
    private String email;
    List<Item> itemList;
    private List<User> sonUserList;

    @Override
    public int compareTo(User otherUser) {
        return this.id.compareTo(otherUser.id);
    }
    public void sortSonUserList() {
        if (sonUserList != null) {
            Collections.sort(sonUserList);
            for (User user : sonUserList) {
                user.sortSonUserList();
            }
        }
        if (itemList != null) {
            Collections.sort(itemList);
        }
    }
}